package com.demo.bean;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Validation注解
 *
 * @author lxiiaodong
 * @date 2022/9/05 15:03 */

public class ValidationBeanModel {

    @Setter
    @Getter
    public class AbcAssertFalse {

        @AssertFalse//	@AssertFalse 可以为null, 如果不为null的话必须为false
        private Boolean myAssertFalse;
    }

    @Setter
    @Getter
    public class AbcAssertTrue {

        @AssertTrue//	@AssertTrue 可以为null, 如果不为null的话必须为true
        private Boolean myAssertTrue;
    }

    @Setter
    @Getter
    public class AbcDecimalMax {

        @DecimalMax(value = "12.3")//	@DecimalMax 设置不能超过最大值
        private String myDecimalMax;
    }

    @Setter
    @Getter
    public class AbcDecimalMin {

        @DecimalMin(value = "10.3")//	@DecimalMin 设置不能超过最小值

        private String myDecimalMin;
    }

    @Setter
    @Getter
    public class AbcDigits {

        @Digits(integer = 5, fraction = 3)//@Digits 设置必须是数字且数字整数的位数和小数的位数必须在指定范围内
        private Integer myDigits;
    }

    @Setter
    @Getter
    public class AbcEmail {


        @Email//	@Email 必须是email格式

        private String myEmail;
    }

    @Setter
    @Getter
    public class AbcFuture {

        @Future//@Future 日期必须在当前日期的未来

        private Date myFuture;
    }

    @Setter
    @Getter
    public class AbcLength {

        @Length(min = 5, max = 10)//	@Length 长度必须在指定范围内


        private String myLength;
    }

    @Setter
    @Getter
    public class AbcMax {

        @Max(value = 200)//	@Max 最大不得超过此最大值

        private Long myMax;
    }

    @Setter
    @Getter
    public class AbcMin {

        @Min(value = 100)//@Min 最大不得小于此最小值
        private Long myMin;
    }

    @Setter
    @Getter
    public class AbcNotBlank {

        @NotBlank//	@NotBlank 字符串不能为null, 字符串trim()后也不能等于“”

        private String myStringNotBlank;

        @NotBlank
        private String myObjNotBlank;
    }

    @Setter
    @Getter
    public class AbcNotEmpty {

        @NotEmpty//	@NotEmpty 不能为null，集合、数组、 map等size()不能为0；字符串trim()后可以等于“”

        private String myStringNotEmpty;

        @NotEmpty
        private String myNullNotEmpty;

        @NotEmpty
        private Map<String, Object> myMapNotEmpty;

        @NotEmpty
        private List<Object> myListNotEmpty;

        @NotEmpty
        private Object[] myArrayNotEmpty;
    }

    @Setter
    @Getter
    public class AbcNotNull {

        @NotNull//	@NotNull 不能为null，可以是空
        private String myStringNotNull;

        @NotNull
        private Object myNullNotNull;

        @NotNull
        private Map<String, Object> myMapNotNull;
    }

    @Setter
    @Getter
    public class AbcNull {

        @Null//	@Null 必须为null

        private String myStringNull;

        @Null
        private Map<String, Object> myMapNull;
    }

    @Setter
    @Getter
    public class AbcPast {

        @Past	//@Past 日期必须在当前日期的过去
        private Date myPast;
    }

    @Setter
    @Getter
    public class AbcPattern {

        @Pattern(regexp = "\\d+")//	@Pattern 必须满足指定的正则表达式
        private String myPattern;
        @Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$")
        private String email;
    }

    @Setter
    @Getter
    public class AbcRange {

        @Range(min = 100, max = 100000000000L)//	@Range 值必须在指定范围内

        private Double myRange;
    }

    @Setter
    @Getter
    public class AbcSize {

        @Size(min = 3, max = 5)//	@Size 集合、数组、 map等的size()值必须在指定范围内

        private List<Integer> mySize;
    }

    @Setter
    @Getter
    public class AbcURL {

        @URL//	@URL 必须是一个URL
        private String myURL;
    }








}
